#include "ServiceChargeTransaction.h"
#include "Employee.h"
#include "ServiceCharge.h"
#include "PayrollDatabase.h"
#include "UnionAffiliation.h"

extern PayrollDataBase GpayrollDatabase;
ServiceChargeTransaction::~ServiceChargeTransaction()
{

}

ServiceChargeTransaction::ServiceChargeTransaction(int memberld, long date, double charge)
	: itsMemberld(memberld),
	itsDate(date),
	itsCharge(charge)
{

}

void ServiceChargeTransaction::Execute()
{
	Employee* e = GpayrollDatabase.GetUnionMember(itsMemberld);
	Affiliation* af = e->GetAffiliation();
	if (UnionAffiliation* uaf = dynamic_cast<UnionAffiliation*>(af))
	{
		uaf->AddServiceCharge(itsDate, itsCharge);
	}
}